package reflect;

import java.lang.reflect.Constructor;

public class Test {
    public static void main(String[] args) throws Exception {
        Class cls = Class.forName("reflect.Student");
        //Constructor con1 = cls.getConstructor();
        //Object obj1 = con1.newInstance();
        Object obj1 = cls.newInstance();    //无参构造器实例化对象
        System.out.println(obj1);
        Constructor con2 = cls.getConstructor(String.class, int.class, char.class);
        Object obj2 = con2.newInstance("张三", 18, '男');  //有参构造器实例化对象
        System.out.println(obj2);
    }
}
